class GameController < ActionController::Base

	def list
	  @games = Game.find(:all)
	end
	
	def show
	  @game = Game.find(params[:id], :include => [:positions] )
	  redirect_to :controller => 'position', :action => 'show', :id => @game.positions[0]
	end
	
	def edit
	  @game = Game.find(params[:id])
  end
  
  def update
    @game = Game.find(params[:id])
    if @game.update_attributes(params[:game])
      flash[:notice] = 'Game was successfully updated.'
      redirect_to :action => 'show', :id => @game
    else
      render :action => 'edit'
    end
  end
  
	def destroy
	  game = Game.find(params[:id])  
	  game.destroy
	  redirect_to :action => 'list'
  end
  
  def new
    @game = Game.new
  end
  
	def create
	  @game = Game.new(params[:game])
	  if @game.save
	    flash[:notice] = 'Game was successfully created.'
	    redirect_to :action => 'list'
	  else
	    render :action => 'new'
	  end
	end

end
